/**
 * @Copyright (c) 2017, 家校通信息科技有限公司 All Rights Reserved.
 */
package com.school.teaching.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.school.teaching.dao.ITrackerDao;
import com.school.teaching.dto.TrackerDTO;
import com.school.teaching.entity.Tracker;
import com.school.teaching.exception.ServiceException;
import com.school.teaching.service.TrackerService;
import com.school.teaching.util.UUIDGeneratorUtils;
import com.school.teaching.vo.TrackerVO;

/**
 * @Description 跟踪器业务类
 * @Author hesheng
 * @Date 2017年3月10日 下午3:43:04
 */
@Service
public class TrackerServiceImpl implements TrackerService {

	@Autowired
	private ITrackerDao trackerDao;
	
	@Override
	public void register(TrackerDTO trackerDTO) {
		Tracker tracker = new Tracker();
		tracker.setId(UUIDGeneratorUtils.getUUID());
		tracker.setSn(trackerDTO.getSn());
		tracker.setTel(trackerDTO.getTel());
		tracker.setCreateBy(trackerDTO.getCreateBy());
		
		int count = trackerDao.saveTracker(tracker);
		if (count == 0) {
			throw new ServiceException("数据保存异常");
		}
	}

	@Override
	public TrackerVO getTrackerBySN(String sn) {
		return trackerDao.getTrackerBySN(sn);
	}

}
